package com.x.Part6_thisDemo;

/**
 * ClassName: Account
 * Package: IntelliJ IDEA
 * Description:
 * Written by HanXu
 * Create 2023/10/13 2:12
 */
public class Account {
    private double balance;

    public Account(double initBalance){
        this.balance = initBalance;
    }

    public double getBalance(){
        return balance;
    }

    public void deposit(double amt){
        balance += amt;
        System.out.println("成功存入" + amt + "RMB");
    }

    public void withdraw(double amt){
        if(balance>=amt && amt>0) {
            balance -= amt;
            System.out.println("成功取出" + amt + "RMB");
        }
        else
            System.out.println("余额不足或取款金额有误");
    }
}
